var pageNum = null;
var pageSize = 10;
let vm = new Vue({
    el: '.main-content',
    data: {
        pageInfo: {},
        condition: {
            type: '',
            name: ''
        }
    },

    methods: {


        getPage: function (pageNum, pageSize) {
            selectPage(pageNum, pageSize)
        },

        selectPage2: function (pageNum = 1, pageSize = 10) {
            let type = $("#chosen-select").val();
            this.condition.type = type;
            axios({
                url: `/guguanjia/sysLog/selectPage/${pageNum}/${pageSize}`,
                params: this.condition
            }).then(response => {
                    this.pageInfo = response.data;
            }).catch(error => {
                console.log(error.message)
            })
        },

        toUpdate: function (id) {
            layer.obj = id;
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                title: '编辑',
                closeBtn: 1, //不显示关闭按钮
                anim: 2,
                area: ['80%', '80%'],
                shadeClose: true, //开启遮罩关闭
                content: '/guguanjia/sysLog/toUpdate',
                end: function () {
                    selectPage(pageNum, pageSize);
                }
            })

        },

        doDelete: function (id) {
            console.log("id:" + id)
            layer.msg("是否删除", {
                time: 20000,
                btn: ['是', '否'],
                yes: () => {
                    axios({
                        url: `/guguanjia/sysLog/deleteById/${id}`,
                        data: id
                    }).then(response => {
                        layer.msg("删除成功")
                        this.getPage(pageNum, pageSize)
                    }).catch(error => {
                        layer.msg(error.message)
                    });
                }
            })
        }


    },
    created: function () {
        selectPage(1, 10);
    }

});


function selectPage(pageNum, pageSize) {
    this.pageNum = pageNum;
    this.pageSize = pageSize;
    axios({
        url: `/guguanjia/sysLog/selectPage/${pageNum}/${pageSize}`,
    }).then(response => {
        vm.$data.pageInfo = response.data;
    }).catch(error => {
        console.log(error.message)
    })
}
